<?php include("src/carrusel_cs.php");
@session_start();
$_SESSION['varMenu'] = 'Carrusel'; 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Carrusel</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/jquery.js"></script>

<script>J = jQuery.noConflict()</script>
<style>

         
         .dvhdr1 {
            background:#000000;
            font-family:arial;
            font-size:12px;
			font-weight:bold;
			color:#FFFFFF;
            border:1px solid #C8BA92;
            padding:5px;
            width:250px;
         }
         
         .dvbdy1 {
            background:#FBFBFB;
            font-family:arial;
            font-size:12px;
            border-left:1px solid #C8BA92;
            border-right:1px solid #C8BA92;
            border-bottom:1px solid #C8BA92;
            padding:5px;
            width:250px;
         }


       
</style>

</head>

<body class="style" onload="MM_preloadImages('images/menu3.png','images/menu2.png','images/assignr.png','images/new_taskr.png','images/mailr.png','images/edit_2r.png','images/client_3r.png','images/deleter.png','images/backr.png','images/noter (1).png')">

<div id="container">
  <?php include('header.php');?>
  <div id="mainContent">  
    <?php include('menuTop.php');?>
    <div id="bg">
	 <table  width="80%" align="center" bgcolor="#FFFFFF">

	<tr>
	<td>
	<table border="0" width="100%">
		<tr ><td colspan="2"><input type="button" name="cuyabra" id="cuyabra" value="Cuyabra" onclick="location.href='carrusel.php?carru=1'"/>&nbsp;&nbsp;<input type="button" name="canal" id="canal" value="Canal 13" onclick="location.href='carrusel.php?carru=2'"/>&nbsp;&nbsp;<input type="button" name="emisora" id="emisora" value="Emisora" onclick="location.href='carrusel.php?carru=3'"/></td></tr>
		<tr>
		<td style="font-size:20px" align="center"><strong>Carrusel <?php if(isset($_GET['carru']) && $_GET['carru'] ==1) echo'Cuyabra'; if(isset($_GET['carru']) && $_GET['carru'] ==2) echo 'Canal 13';elseif(isset($_GET['carru']) && $_GET['carru'] ==3)echo'Emisora';?> - Tamaño de la imagen 660x320</strong></td>
		</tr>
		<tr><td colspan="2">&nbsp;</td></tr>
	</table>
	</td>
	</tr>
  <tr align="center">
	  <td>
	  	<form name="form1" id="form1" method="post" action="carrusel.php" enctype="multipart/form-data">
        <input type="hidden" id="carru" name="carru" value="<?php echo $carru;?>" />
		  <div id="list">
          <table border="0" style="border:1px solid #999999">
			<tr>
			  <td valign="top" align="center" >
			  <table border="0" width="100%" cellpadding="0" cellspacing="1">
			  <tr >
			  <td align="center" valign="middle" bgcolor="#000000"><h1>Imagen</h1></td>
			  <td align="center" valign="middle" bgcolor="#000000"><h1>Nombre de la Imagen</h1></td>
			  <td align="center" valign="middle" bgcolor="#000000"><h1>Posición de rotación</h1></td>
			  <td align="center" valign="middle" bgcolor="#000000"><h1>Eliminar</h1></td>
			  </tr>
			  <?php for($i=0;$i<count($lista);$i++){
				if($i%2 == 0)
					$color = '#FBFBFB';
				else
					$color = '#FBFBFB';
			  ?>
			  
			  <tr bgcolor="<?php echo $color ?>">
			    <td width="19%" align="center"><a href="../file_upload/carrusel/500x500/<?php echo $lista[$i]->renombre?>"
onclick="return GB_showImage('<?php echo $lista[$i]->nombre?>', this.href)"><img src="../file_upload/carrusel/50x50/<?php echo $lista[$i]->renombre; ?>" border="0"/></a></td>				
			  	<td align="left"><?php echo $lista[$i]->nombre; ?></td>
				<td align="center"><input type="text" size="2" name="pos_<?php echo $lista[$i]->codigo;?>" value="<?php echo $lista[$i]->position;?>"/></td>
				<td align="center"><a href="carrusel.php?cod=<?php echo $lista[$i]->codigo;?>&del=1&carru=<?php echo $_GET['carru'];?>" onclick="javascript: return validarEliminacion();"><img width="32" height="32" src="../images/delet.png" border="0" alt="Image no cargada"/></a></td>
			  </tr>
			  <?php }?>		
			  <tr>
			  	<td colspan="2">&nbsp;</td>
				<td><input name="submit" type="submit" onclick="javascript: return validador2();" value="Guardar Orden" style="font-size:9px"/></td>
			  </tr>	  
			  </table>			  
			  </td>
			</tr>
			<tr>
			
			  	<!--<td width="5%" align="center">&nbsp;</td>-->
			  <td>
			  
				  <input type="hidden" name="agregar" id="agregar" value="1"/>
				  <input type="file" name="imagen" id="imagen" />
				  <input type="text" name="nombre" id="nombre" size="50"/>
				  <input name="submit" type="submit" onclick="javascript: return validador();" value="Agregar Imagen"/>
			  
			  </td>
		
			
			  </tr>
		  </table>
          </div>
	 	</form>
	  </td>
  </tr>
  <tr><td>&nbsp;</td></tr>
</table>
    </div>
    <br />
    <br />
    <!-- end #mainContent -->
  </div>
  <?php include('footer.php');?>
<!-- end #container --></div>

</body>
</html>
<script language="javascript" type="text/javascript">
function validarEliminacion()
{
 	
	if(window.confirm("¿Esta seguro de eliminar la imagen?"))
		return true;
	else
		return false;

}


function validador2() 
{
	f = window.document.form1;
	document.getElementById('agregar').value = 2;
	f.submit();
}

function validador() 
{

	f = window.document.form1;
	var msj = '';
	
   if(document.getElementById('nombre').value == '')
		msj = msj+'The field name is required \n';
   	
   if(document.getElementById("imagen").value == "" ){
	   msj = msj+'The field image is required \n';
	 }	


  if(document.getElementById("imagen").value != "" ){
    var nom = document.getElementById("imagen").value;
	var nom2 = (nom.substring(nom.lastIndexOf("."))).toLowerCase();	
	var extensiones_permitidas = new Array(".jpg",".JPG",".png", ".PNG",".jpeg",".JPEG",".gif",".GIF",".bmp"); 
	var permitida = false; 
	for(var i = 0; i < extensiones_permitidas.length; i++){ 
 	  if(extensiones_permitidas[i] == nom2){ 
		permitida = true; 
		break; 
	  } 
	} 

   if(!permitida){	   
   msj = msj+'The image can have only extension .jpg, .JPG, .png, .PNG, .jpeg, .JPEG, .gif, .GIF, .bmp';
	}
  }

	if(msj != '')
	{
		alert(msj);
		return false;
	}
	else
	{
		f.submit();		
		return true;
	}

}

function mostrarEmergente(codigo)
{            
	url = "../../admin/editCarrusel.php?cod="+codigo;
	//alert(url);
	GB_showCenter(" Edit Image ", url,400,500);
	
}
</script>